package org.example.innovate.controller;
import com.alibaba.fastjson.JSONObject;
import kong.unirest.HttpResponse;
import kong.unirest.Unirest;
import org.example.innovate.dto.PageDTO;
import jakarta.annotation.Resource;
import org.codehaus.jettison.json.JSONException;
import org.example.innovate.common.CommonResponse;
import org.example.innovate.domain.Dish;
import org.example.innovate.service.DishService;
import org.example.innovate.vo.DishBodyVo;
import org.example.innovate.vo.DishOneVo;
import org.example.innovate.vo.DishVo;
import org.springframework.web.bind.annotation.*;
import com.alibaba.fastjson.JSON;

import javax.validation.Valid;
import java.io.IOException;

import java.util.List;
@RestController
public class AIController {
    @PostMapping("/aitest")
    public CommonResponse<String> update() throws org.codehaus.jettison.json.JSONException {
        HttpResponse<String> response = Unirest.post("https://api.siliconflow.cn/v1/chat/completions")
                .header("Authorization", "Bearer sk-cqtkakdtwdnzxwtvwccjptewtdwwhjkfmztztupogtyivxbm")
                .header("Content-Type", "application/json")
                .body("{\n  \"model\": \"deepseek-ai/DeepSeek-V3\",\n  \"messages\": [\n    {\n      \"role\": \"user\",\n      \"content\": \"中国大模型行业2025年将会迎来哪些机遇和挑战？\"\n    }\n  ],\n  \"stream\": false,\n  \"max_tokens\": 512,\n  \"stop\": [\n    \"null\"\n  ],\n  \"temperature\": 0.7,\n  \"top_p\": 0.7,\n  \"top_k\": 50,\n  \"frequency_penalty\": 0.5,\n  \"n\": 1,\n  \"response_format\": {\n    \"type\": \"text\"\n  },\n  \"tools\": [\n    {\n      \"type\": \"function\",\n      \"function\": {\n        \"description\": \"<string>\",\n        \"name\": \"<string>\",\n        \"parameters\": {},\n        \"strict\": false\n      }\n    }\n  ]\n}")
                .asString();
        System.out.println(response.getBody());
        return CommonResponse.createForSuccess(response.getBody());
    }
    }

